


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Message send semantics &mdash; Akka Documentation</title>
    
    <link rel="stylesheet" href="../_static/style.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/prettify.css" type="text/css" />
    <link rel="stylesheet" href="../_static/base.css" type="text/css" />
    <link rel="stylesheet" href="../_static/docs.css" type="text/css" />
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Exo:300,400,600,700" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/toc.js"></script>
    <script type="text/javascript" src="../_static/prettify.js"></script>
    <script type="text/javascript" src="../_static/highlightCode.js"></script>
    <script type="text/javascript" src="../_static/effects.core.js"></script>
    <script type="text/javascript" src="../_static/effects.highlight.js"></script>
    <script type="text/javascript" src="../_static/scrollTo.js"></script>
    <script type="text/javascript" src="../_static/contentsFix.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="top" title="Akka Documentation" href="../index.html" />
    <link rel="up" title="General" href="index.html" />
    <link rel="next" title="Configuration" href="configuration.html" />
    <link rel="prev" title="Akka and the Java Memory Model" href="jmm.html" /> 
  </head>
  <body>
  <div class="navbar">
    <div class="navbar-inner">
      <div class="container">
        <div class="navbar-logo">
          <a href="http://akka.io"><img src="../_static/logo-small.png" /></a>
        </div>    
        <ul class="nav">
          <li><a href="http://akka.io/docs">Documentation</a></li>
          <li><a href="http://akka.io/downloads">Download</a></li>
          <li><a href="http://groups.google.com/group/akka-user">Mailing List</a></li>
          <li><a href="http://github.com/akka/akka">Code</a></li>           
          <li><a href="http://typesafe.com/products/typesafe-subscription">Commerical Support</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="main">
    <div class="container">
      <div class="page-title">Message send semantics</div><div class="pdf-link"><a href="http://akka.io/docs/akka/2.0.1/Akka.pdf"><img src="../_static/pdf-icon.png" style="height: 40px;" /></a></div></div>
    <div class="main-container">
      <div class="container">
        <div class="row">
          <div class="span12">
            <ul class="breadcrumb">           
              <li>
                 <span class="divider">|</span> <a href="configuration.html">Configuration</a> <span class="divider">»</span>
              </li>
              <li>
                <a href="../index.html">Contents</a>
              </li>
              <li>
                <span class="divider">«</span> <a href="jmm.html">Akka and the Java Memory Model</a> <span class="divider">|</span>
              </li>
              <li>
                Version 2.0.1
              </li>
            </ul>         
          </div>
        </div>
        <div class="row">
          <div class="span9">
            
  <div class="section" id="message-send-semantics">
<span id="id1"></span><h1>Message send semantics</h1>
<div class="section" id="guaranteed-delivery">
<h2>Guaranteed Delivery?</h2>
<p>Akka does <em>not</em> support guaranteed delivery.</p>
<p>First it is close to impossible to actually give guarantees like that,
second it is extremely costly trying to do so.
The network is inherently unreliable and there is no such thing as 100%
guarantee delivery, so it can never be guaranteed.</p>
<p>The question is what to guarantee. That:</p>
<ol class="arabic simple">
<li>The message is sent out on the network?</li>
<li>The message is received by the other host?</li>
<li>The message is put on the target actor&#8217;s mailbox?</li>
<li>The message is applied to the target actor?</li>
<li>The message is starting to be executed by the target actor?</li>
<li>The message is finished executing by the target actor?</li>
</ol>
<p>Each one of this have different challenges and costs.</p>
<p>Akka embraces distributed computing and the network and makes it explicit
through message passing, therefore it does not try to lie and emulate a
leaky abstraction. This is a model that have been used with great success
in Erlang and requires the user to model his application around. You can
read more about this approach in the <a class="reference external" href="http://www.erlang.org/faq/academic.html">Erlang documentation</a> (section
10.9 and 10.10), Akka follows it closely.</p>
<p>Bottom line: you as a developer know what guarantees you need in your
application and can solve it fastest and most reliable by explicit <tt class="docutils literal"><span class="pre">ACK</span></tt> and
<tt class="docutils literal"><span class="pre">RETRY</span></tt> (if you really need it, most often you don&#8217;t). Using Akka&#8217;s Durable
Mailboxes could help with this.</p>
</div>
<div class="section" id="delivery-semantics">
<h2>Delivery semantics</h2>
<div class="section" id="at-most-once">
<h3>At-most-once</h3>
<p>Actual transports may provide stronger semantics,
but at-most-once is the semantics you should expect.
The alternatives would be once-and-only-once, which is extremely costly,
or at-least-once which essentially requires idempotency of message processing,
which is a user-level concern.</p>
</div>
<div class="section" id="ordering-is-preserved-on-a-per-sender-basis">
<h3>Ordering is preserved on a per-sender basis</h3>
<p>Actor <tt class="docutils literal"><span class="pre">A1`</span> <span class="pre">sends</span> <span class="pre">messages</span> <span class="pre">``M1</span></tt>, <tt class="docutils literal"><span class="pre">M2</span></tt>, <tt class="docutils literal"><span class="pre">M3</span></tt> to <tt class="docutils literal"><span class="pre">A2</span></tt>
Actor <tt class="docutils literal"><span class="pre">A3</span></tt> sends messages <tt class="docutils literal"><span class="pre">M4</span></tt>, <tt class="docutils literal"><span class="pre">M5</span></tt>, <tt class="docutils literal"><span class="pre">M6</span></tt> to <tt class="docutils literal"><span class="pre">A2</span></tt></p>
<dl class="docutils">
<dt>This means that:</dt>
<dd><ol class="first last arabic simple">
<li>If <tt class="docutils literal"><span class="pre">M1</span></tt> is delivered it must be delivered before <tt class="docutils literal"><span class="pre">M2</span></tt> and <tt class="docutils literal"><span class="pre">M3</span></tt></li>
<li>If <tt class="docutils literal"><span class="pre">M2</span></tt> is delivered it must be delivered before <tt class="docutils literal"><span class="pre">M3</span></tt></li>
<li>If <tt class="docutils literal"><span class="pre">M4</span></tt> is delivered it must be delivered before <tt class="docutils literal"><span class="pre">M5</span></tt> and <tt class="docutils literal"><span class="pre">M6</span></tt></li>
<li>If <tt class="docutils literal"><span class="pre">M5</span></tt> is delivered it must be delivered before <tt class="docutils literal"><span class="pre">M6</span></tt></li>
<li><tt class="docutils literal"><span class="pre">A2</span></tt> can see messages from <tt class="docutils literal"><span class="pre">A1</span></tt> interleaved with messages from <tt class="docutils literal"><span class="pre">A3</span></tt></li>
<li>Since there is no guaranteed delivery, none, some or all of the messages may arrive to <tt class="docutils literal"><span class="pre">A2</span></tt></li>
</ol>
</dd>
</dl>
</div>
</div>
</div>


          </div>
          <div class="span3"><p class="contents-title">Contents</p>
              <div id="scroller-anchor">
                <div id="scroller">
                  <div id="toc"></div>
                </div>
              </div></div>
        </div>
      </div>
    </div>
  </div>
  <div class="footer">
  <div class="container">
    <ul>
      <li><h5>Akka</h5></li>
      <li><a href="http://akka.io/docs">Documentation</a></li>
      <li><a href="http://akka.io/downloads">Downloads</a></li>
    </ul>
    <ul>
      <li><h5>Contribute</h5></li>
      <li><a href="http://github.com/akka/akka">Source Code</a></li>
      <li><a href="http://groups.google.com/group/akka-user">Mailing List</a></li>      
      <li><a href="http://www.assembla.com/spaces/akka/tickets">Report a Bug</a></li>      
    </ul>
    <ul>
      <li><h5>Company</h5></li>
      <li><a href="http://typesafe.com/products/typesafe-subscription">Commercial Support</a></li>
      <li><a href="http://akka.io/team">Team</a></li>
      <li><a href="mailto:info@typesafe.com">Contact</a></li>
    </ul>
    <ul>
      <li><img src="../_static/watermark.png" align="center"/></li>
    </ul>
  </div>
  <div class="container copyright">
    <p style="float: left;">
      © 2012 <a href="http://typesafe.com/">Typesafe Inc.</a> <span class="license">Akka is Open Source and available under the Apache 2 License.</span>
    </p>
    <p style="float: right; font-size: 12px;">
      Last updated: Apr 13, 2012
    </p>          
  </div>
</div>
<script type="text/javascript">
  $('#toc').toc();
</script>
  

  </body>
</html>